package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11)"`
	Password string `gorm:"type:varchar(32)"`
}
type UserRealname struct {
	gorm.Model
	UserId   int    `gorm:"type:int"`
	Realname string `gorm:"type:varchar(30)"`
	Idcard   string `gorm:"type:varchar(18)"`
}

func (u *User) GetUserByMobile() error {
	return DB.Where("mobile = ?", u.Mobile).Limit(1).Find(&u).Error
}
func (u *User) Create() error {
	return DB.Create(&u).Error
}

func (ur *UserRealname) Create() error {
	return DB.Create(&ur).Error
}
func (ur *UserRealname) GetUserRealnameByUserId() error {
	return DB.Where("user_id = ?", ur.UserId).Limit(1).Find(&ur).Error
}
